import {
  direction,
  familyLevel,
  eachOther,
  fiveElements,
  diagramElement,
} from "./enums.js";

export const heavenStems = {
  甲: {
    name: "甲",
    element: fiveElements.木,
    yinyang: true,
  },
  乙: {
    name: "乙",
    element: fiveElements.木,
    yinyang: false,
  },
  丙: {
    name: "丙",
    element: fiveElements.火,
    yinyang: true,
  },
  丁: {
    name: "丁",
    element: fiveElements.火,
    yinyang: false,
  },
  戊: {
    name: "戊",
    element: fiveElements.土,
    yinyang: true,
  },
  己: {
    name: "己",
    element: fiveElements.土,
    yinyang: false,
  },
  庚: {
    name: "庚",
    element: fiveElements.金,
    yinyang: true,
  },
  辛: {
    name: "辛",
    element: fiveElements.金,
    yinyang: false,
  },
  壬: {
    name: "壬",
    element: fiveElements.水,
    yinyang: true,
  },
  癸: {
    name: "癸",
    element: fiveElements.水,
    yinyang: false,
  },
};

export const earthBranches = {
  子: {
    name: "子",
    element: fiveElements.水,
    yinyang: false,
  },
  丑: {
    name: "丑",
    element: fiveElements.土,
    yinyang: true,
  },
  寅: {
    name: "寅",
    element: fiveElements.木,
    yinyang: false,
  },
  卯: {
    name: "卯",
    element: fiveElements.木,
    yinyang: true,
  },
  辰: {
    name: "辰",
    element: fiveElements.土,
    yinyang: false,
  },
  巳: {
    name: "巳",
    element: fiveElements.火,
    yinyang: true,
  },
  午: {
    name: "午",
    element: fiveElements.火,
    yinyang: false,
  },
  未: {
    name: "未",
    element: fiveElements.土,
    yinyang: true,
  },
  申: {
    name: "申",
    element: fiveElements.金,
    yinyang: false,
  },
  酉: {
    name: "酉",
    element: fiveElements.金,
    yinyang: true,
  },
  戌: {
    name: "戌",
    element: fiveElements.土,
    yinyang: false,
  },
  亥: {
    name: "亥",
    element: fiveElements.水,
    yinyang: true,
  },
};

const colors = {
  木: "#259b24",
  火: "#e51c23",
  土: "chocolate",
  金: "gold",
  水: "#5677fc",
  火1: "#ff4081",
  土1: "burlywood",
  金1: "goldenrod",
  水1: "#03a9f4",
  木1: "#5af158", //没用
};

export const relation = {
  combine3: [
    {
      factors: [earthBranches.申, earthBranches.子, earthBranches.辰],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.巳, earthBranches.酉, earthBranches.丑],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.亥, earthBranches.卯, earthBranches.未],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.寅, earthBranches.午, earthBranches.戌],
      result: fiveElements.火,
      color: colors.火,
    },
  ],
  combine3f: [
    {
      factors: [earthBranches.亥, earthBranches.子, earthBranches.丑],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.寅, earthBranches.卯, earthBranches.辰],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.巳, earthBranches.午, earthBranches.未],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.申, earthBranches.酉, earthBranches.戌],
      result: fiveElements.金,
      color: colors.金,
    },
  ],
  combine6: [
    {
      factors: [earthBranches.子, earthBranches.丑],
      result: fiveElements.土,
      color: colors.土,
    },
    {
      factors: [earthBranches.寅, earthBranches.亥],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.辰, earthBranches.酉],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.午, earthBranches.未],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.申, earthBranches.巳],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.卯, earthBranches.戌],
      result: fiveElements.木,
      color: colors.木1,
    },
  ],
  combineHalf: [
    {
      factors: [earthBranches.申, earthBranches.子],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.申, earthBranches.辰],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.辰, earthBranches.子],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.亥, earthBranches.卯],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.亥, earthBranches.未],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.卯, earthBranches.未],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.巳, earthBranches.酉],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.巳, earthBranches.丑],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.酉, earthBranches.丑],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.寅, earthBranches.午],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.寅, earthBranches.戌],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.戌, earthBranches.午],
      result: fiveElements.火,
      color: colors.火,
    },
  ],
  impact: [
    {
      factors: [earthBranches.子, earthBranches.午],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.卯, earthBranches.酉],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.辰, earthBranches.戌],
      result: fiveElements.土,
      color: colors.土,
    },
    {
      factors: [earthBranches.丑, earthBranches.未],
      result: fiveElements.土,
      color: colors.土1,
    },
    {
      factors: [earthBranches.寅, earthBranches.申],
      result: fiveElements.金,
      color: colors.金1,
    },
    {
      factors: [earthBranches.巳, earthBranches.亥],
      result: fiveElements.水,
      color: colors.水1,
    },
  ],
  tomb: [
    {
      factors: [earthBranches.辰],
      result: fiveElements.水,
      color: colors.水,
    },
    {
      factors: [earthBranches.未],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.戌],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.丑],
      result: fiveElements.金,
      color: colors.金,
    }
  ],
  born: [ //长生
    {
      factors: [earthBranches.亥],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.寅],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.巳],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.申],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  shower: [
    {
      factors: [earthBranches.子],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.卯],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.午],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.酉],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  king: [
    {
      factors: [earthBranches.卯],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.午],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.酉],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.子],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  ill: [
    {
      factors: [earthBranches.巳],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.申],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.亥],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.寅],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  dead: [
    {
      factors: [earthBranches.午],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.酉],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.子],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.卯],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  weak: [
    {
      factors: [earthBranches.辰],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.未],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.戌],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.丑],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  adult: [
    {
      factors: [earthBranches.丑],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.辰],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.未],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.戌],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  official: [
    {
      factors: [earthBranches.寅],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.巳],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.申],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.亥],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  embryo: [
    {
      factors: [earthBranches.酉],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.子],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.卯],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.午],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  germination: [
    {
      factors: [earthBranches.戌],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.丑],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.辰],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.未],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  end: [
    {
      factors: [earthBranches.申],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.亥],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.寅],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.巳],
      result: fiveElements.水,
      color: colors.水,
    },
  ],
  penalty: [
    {
      factors: [earthBranches.巳, earthBranches.申],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.申, earthBranches.寅],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.寅, earthBranches.巳],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.丑, earthBranches.戌],
      result: fiveElements.土,
      color: colors.土,
    },
    {
      factors: [earthBranches.戌, earthBranches.未],
      result: fiveElements.土,
      color: colors.土,
    },
    {
      factors: [earthBranches.未, earthBranches.丑],
      result: fiveElements.土,
      color: colors.土,
    },
    {
      factors: [earthBranches.子, earthBranches.卯],
      result: fiveElements.木,
      color: colors.木,
    }
  ],
  snare: [
    {
      factors: [earthBranches.寅, earthBranches.巳],
      result: fiveElements.火,
      color: colors.火,
    },
    {
      factors: [earthBranches.丑, earthBranches.午],
      result: fiveElements.土,
      color: colors.土,
    },
    {
      factors: [earthBranches.子, earthBranches.未],
      result: fiveElements.土,
      color: colors.土1,
    },
    {
      factors: [earthBranches.亥, earthBranches.申],
      result: fiveElements.金,
      color: colors.金,
    },
    {
      factors: [earthBranches.卯, earthBranches.辰],
      result: fiveElements.木,
      color: colors.木,
    },
    {
      factors: [earthBranches.戌, earthBranches.酉],
      result: fiveElements.金,
      color: colors.金1,
    },
  ]
};

// earthBranches.子.relation = {
//   combine3: {
//     factors: [earthBranches.申, earthBranches.辰],
//     result: fiveElements.水,
//   },
//   combine6: {
//     factors: [earthBranches.丑],
//     result: fiveElements.土,
//   },
//   impact: earthBranches.午,
//   tomb: earthBranches.辰,
//   penalty: [earthBranches.卯],

//   impactResult: fiveElements.水,
//   tombResult: fiveElements.水,
//   penaltyResult: fiveElements.水,
// };
// earthBranches.丑.relation = {
//   combine3: [earthBranches.巳, earthBranches.酉],
//   combine6: earthBranches.子,
//   impact: earthBranches.未,
//   penalty: [earthBranches.戌, earthBranches.未],
//   combine3Result: fiveElements.金,
//   combine6Result: fiveElements.土,
//   impactResult: fiveElements.土,
//   tombResult: fiveElements.木,
//   penaltyResult: fiveElements.土,
// };
// earthBranches.寅.relation = {
//   combine3: [earthBranches.午, earthBranches.戌],
//   combine6: earthBranches.亥,
//   impact: earthBranches.申,
//   tomb: earthBranches.未,
//   penalty: [earthBranches.巳, earthBranches.申],
//   combine3Result: fiveElements.火,
//   combine6Result: fiveElements.木,
//   impactResult: fiveElements.金,
//   tombResult: fiveElements.木,
//   penaltyResult: fiveElements.火,
// };
// earthBranches.卯.relation = {
//   combine3: [earthBranches.亥, earthBranches.未],
//   combine6: earthBranches.戌,
//   impact: earthBranches.酉,
//   tomb: earthBranches.未,
//   penalty: [earthBranches.子],
//   combine3Result: fiveElements.木,
//   combine6Result: fiveElements.火,
//   impactResult: fiveElements.金,
//   tombResult: fiveElements.木,
//   penaltyResult: fiveElements.水,
// };
// earthBranches.辰.relation = {
//   combine3: [earthBranches.申, earthBranches.子],
//   combine6: earthBranches.酉,
//   impact: earthBranches.戌,
// };
// earthBranches.巳.relation = {
//   combine3: [earthBranches.酉, earthBranches.丑],
//   combine6: earthBranches.申,
//   impact: earthBranches.亥,
//   tomb: earthBranches.戌,
//   penalty: [earthBranches.寅, earthBranches.申],
// };
// earthBranches.午.relation = {
//   combine3: [earthBranches.寅, earthBranches.戌],
//   combine6: earthBranches.未,
//   impact: earthBranches.子,
//   tomb: earthBranches.戌,
// };

// earthBranches.未.relation = {
//   combine3: [earthBranches.亥, earthBranches.卯],
//   combine6: earthBranches.午,
//   impact: earthBranches.丑,
//   penalty: [earthBranches.丑, earthBranches.戌],
// };

// earthBranches.申.relation = {
//   combine3: [earthBranches.子, earthBranches.辰],
//   combine6: earthBranches.巳,
//   impact: earthBranches.寅,
//   tomb: earthBranches.丑,
//   penalty: [earthBranches.寅, earthBranches.巳],
// };

// earthBranches.酉.relation = {
//   combine3: [earthBranches.巳, earthBranches.丑],
//   combine6: earthBranches.辰,
//   impact: earthBranches.卯,
//   tomb: earthBranches.丑,
// };

// earthBranches.戌.relation = {
//   combine3: [earthBranches.寅, earthBranches.午],
//   combine6: earthBranches.卯,
//   impact: earthBranches.辰,
//   penalty: [earthBranches.丑, earthBranches.未],
// };

// earthBranches.亥.relation = {
//   combine3: [earthBranches.卯, earthBranches.未],
//   combine6: earthBranches.寅,
//   impact: earthBranches.巳,
//   tomb: earthBranches.辰,
// };

export const basicEightDiagrams = {
  乾: {
    name: "乾",
    diagramElement: diagramElement.天,
    element: fiveElements.金,
    symbols: [true, true, true],
    direction: direction.WN,
    level: familyLevel.father,
    earthBranches: [
      earthBranches.子,
      earthBranches.寅,
      earthBranches.辰,
      earthBranches.午,
      earthBranches.申,
      earthBranches.戌,
    ],
    heavenStems: [heavenStems.甲, heavenStems.壬],
    ancientNumber: 1,
  },
  坎: {
    name: "坎",
    diagramElement: diagramElement.水,
    element: fiveElements.水,
    symbols: [false, true, false],
    direction: direction.N,
    level: familyLevel.son2,
    earthBranches: [
      earthBranches.寅,
      earthBranches.辰,
      earthBranches.午,
      earthBranches.申,
      earthBranches.戌,
      earthBranches.子,
    ],
    heavenStems: [heavenStems.戊, heavenStems.戊],
    ancientNumber: 6,
  },
  艮: {
    name: "艮",
    diagramElement: diagramElement.山,
    element: fiveElements.土,
    symbols: [false, false, true],
    direction: direction.EN,
    level: familyLevel.son3,
    earthBranches: [
      earthBranches.辰,
      earthBranches.午,
      earthBranches.申,
      earthBranches.戌,
      earthBranches.子,
      earthBranches.寅,
    ],
    heavenStems: [heavenStems.丙, heavenStems.丙],
    ancientNumber: 7,
  },
  震: {
    name: "震",
    diagramElement: diagramElement.雷,
    element: fiveElements.木,
    symbols: [true, false, false],
    direction: direction.E,
    level: familyLevel.son1,
    earthBranches: [
      earthBranches.子,
      earthBranches.寅,
      earthBranches.辰,
      earthBranches.午,
      earthBranches.申,
      earthBranches.戌,
    ],
    heavenStems: [heavenStems.庚, heavenStems.庚],
    ancientNumber: 4,
  },
  巽: {
    name: "巽",
    diagramElement: diagramElement.风,
    element: fiveElements.木,
    symbols: [false, true, true],
    direction: direction.ES,
    level: familyLevel.daughter1,
    earthBranches: [
      earthBranches.丑,
      earthBranches.亥,
      earthBranches.酉,
      earthBranches.未,
      earthBranches.巳,
      earthBranches.卯,
    ],
    heavenStems: [heavenStems.辛, heavenStems.辛],
    ancientNumber: 5,
  },
  离: {
    name: "离",
    diagramElement: diagramElement.火,
    element: fiveElements.火,
    symbols: [true, false, true],
    direction: direction.S,
    level: familyLevel.daughter2,
    earthBranches: [
      earthBranches.卯,
      earthBranches.丑,
      earthBranches.亥,
      earthBranches.酉,
      earthBranches.未,
      earthBranches.巳,
    ],
    heavenStems: [heavenStems.己, heavenStems.乙],
    ancientNumber: 3,
  },
  坤: {
    name: "坤",
    diagramElement: diagramElement.地,
    element: fiveElements.土,
    symbols: [false, false, false],
    direction: direction.WS,
    level: familyLevel.mother,
    earthBranches: [
      earthBranches.未,
      earthBranches.巳,
      earthBranches.卯,
      earthBranches.丑,
      earthBranches.亥,
      earthBranches.酉,
    ],
    heavenStems: [heavenStems.乙, heavenStems.庚],
    ancientNumber: 8,
  },
  兑: {
    name: "兑",
    diagramElement: diagramElement.泽,
    element: fiveElements.金,
    symbols: [true, true, false],
    direction: direction.W,
    level: familyLevel.daughter3,
    earthBranches: [
      earthBranches.巳,
      earthBranches.卯,
      earthBranches.丑,
      earthBranches.亥,
      earthBranches.酉,
      earthBranches.未,
    ],
    heavenStems: [heavenStems.丁, heavenStems.丁],
    ancientNumber: 2,
  },
};

export const eightDiagrams = {
  乾: {
    name: "乾",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.乾,
    yinyang: true,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.乾,
    tip: "强健 启始"
  },
  坎: {
    name: "坎",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.坎,
    yinyang: true,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.坎,
    tip: "坎凹 陷入"
  },
  艮: {
    name: "艮",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.艮,
    yinyang: true,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.艮,
    tip: "堆积 受阻"
  },
  震: {
    name: "震",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.震,
    yinyang: true,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.震,
    tip: "突发 走动"
  },
  巽: {
    name: "巽",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.巽,
    yinyang: false,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.巽,
    tip: "跟风 上行下效"
  },
  离: {
    name: "离",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.离,
    yinyang: false,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.离,
    tip: "外露 绚丽"
  },
  坤: {
    name: "坤",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.坤,
    yinyang: false,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.坤,
    tip: "包含 承载"
  },
  兑: {
    name: "兑",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.兑,
    yinyang: false,
    eachOther: eachOther.纯卦,
    host: basicEightDiagrams.兑,
    tip: "谈话 愉悦"
  },
};

export const sixtyFourDiagrams = {
  ...eightDiagrams,
  姤: {
    name: "姤",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.一世,
    tip: "疏漏 相遇"
  },
  遁: {
    name: "遁",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.二世,
    tip: "逃遁 隐退"
  },
  否: {
    name: "否",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.三世,
    tip: "受阻 闭塞"
  },
  观: {
    name: "观",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.四世,
    tip: "考察 观望"
  },
  剥: {
    name: "剥",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.五世,
    tip: "剥落 显露"
  },
  晋: {
    name: "晋",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.游魂,
    tip: "晋升 前进"
  },
  大有: {
    name: "大有",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.乾,
    eachOther: eachOther.归魂,
    tip: "收货 丰富"
  },
  节: {
    name: "节",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.一世,
    tip: "节度 制约"
  },
  屯: {
    name: "屯",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.二世,
    tip: "屯积 初始"
  },
  既济: {
    name: "既济",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.三世,
    tip: "顺其自然 顺畅"
  },
  革: {
    name: "革",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.四世,
    tip: "改革 革新"
  },
  丰: {
    name: "丰",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.五世,
    tip: "丰富 张扬"
  },
  明夷: {
    name: "明夷",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.游魂,
    tip: "前有险 动则伤"
  },
  师: {
    name: "师",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.坎,
    eachOther: eachOther.归魂,
    tip: "单一 率众"
  },
  贲: {
    name: "贲",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.一世,
    tip: "粉饰 礼仪"
  },
  大畜: {
    name: "大畜",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.二世,
    tip: "积蓄已久 准备充分"
  },
  损: {
    name: "损",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.三世,
    tip: "损失 受损"
  },
  睽: {
    name: "睽",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.四世,
    tip: "反目 背驰"
  },
  履: {
    name: "履",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.五世,
    tip: "履行 持礼"
  },
  中孚: {
    name: "中孚",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.游魂,
    tip: "坚持 诚信"
  },
  渐: {
    name: "渐",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.艮,
    eachOther: eachOther.归魂,
    tip: "渐近 缓近"
  },
  豫: {
    name: "豫",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.震,
    eachOther: eachOther.一世,
    tip: "欢愉 犹豫"
  },
  解: {
    name: "解",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.震,
    eachOther: eachOther.二世,
    tip: "解决 释放"
  },
  恒: {
    name: "恒",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.震,
    eachOther: eachOther.三世,
    tip: "恒久 不变"
  },
  升: {
    name: "升",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.震,
    eachOther: eachOther.四世,
    tip: "进展 提升"
  },
  井: {
    name: "井",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.震,
    eachOther: eachOther.五世,
    tip: "规划 局束"
  },
  大过: {
    name: "大过",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.震,
    eachOther: eachOther.游魂,
    tip: "太过分 已遭损失"
  },
  随: {
    name: "随",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.震,
    eachOther: eachOther.归魂,
    tip: "跟随 归顺"
  },
  小畜: {
    name: "小畜",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.一世,
    tip: "浅积累 欠充分"
  },
  家人: {
    name: "家人",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.二世,
    tip: "亲人 归家 回收"
  },
  益: {
    name: "益",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.三世,
    tip: "有益 受益"
  },
  无妄: {
    name: "无妄",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.四世,
    tip: "无妄为 无过失"
  },
  噬嗑: {
    name: "噬嗑",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.五世,
    tip: "沟通 有目的交流"
  },
  颐: {
    name: "颐",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.游魂,
    tip: "颐表 培养"
  },
  蛊: {
    name: "蛊",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.巽,
    eachOther: eachOther.归魂,
    tip: "发动 谋事"
  },
  旅: {
    name: "旅",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.离,
    eachOther: eachOther.一世,
    tip: "旅行 客居"
  },
  鼎: {
    name: "鼎",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.巽,
    host: basicEightDiagrams.离,
    eachOther: eachOther.二世,
    tip: "独当一面 极致"
  },
  未济: {
    name: "未济",
    top: basicEightDiagrams.离,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.离,
    eachOther: eachOther.三世,
    tip: "阻碍 未达目的"
  },
  蒙: {
    name: "蒙",
    top: basicEightDiagrams.艮,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.离,
    eachOther: eachOther.四世,
    tip: "启蒙 不清晰"
  },
  涣: {
    name: "涣",
    top: basicEightDiagrams.巽,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.离,
    eachOther: eachOther.五世,
    tip: "涣散 发散"
  },
  讼: {
    name: "讼",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.离,
    eachOther: eachOther.游魂,
    tip: "谈判 诉讼"
  },
  同人: {
    name: "同人",
    top: basicEightDiagrams.乾,
    bottom: basicEightDiagrams.离,
    host: basicEightDiagrams.离,
    eachOther: eachOther.归魂,
    tip: "随大流 与众同等"
  },
  复: {
    name: "复",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.震,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.一世,
    tip: "反复 重复"
  },
  临: {
    name: "临",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.二世,
    tip: "临近 降临"
  },
  泰: {
    name: "泰",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.三世,
    tip: "通泰 通畅"
  },
  大壮: {
    name: "大壮",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.四世,
    tip: "众所周知 正当其用"
  },
  夬: {
    name: "夬",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.五世,
    tip: "缺陷 不完整"
  },
  需: {
    name: "需",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.乾,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.游魂,
    tip: "等待 筹备"
  },
  比: {
    name: "比",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.坤,
    eachOther: eachOther.归魂,
    tip: "亲密 平等"
  },
  困: {
    name: "困",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.坎,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.一世,
    tip: "受困 被围"
  },
  萃: {
    name: "萃",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.坤,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.二世,
    tip: "突出 聚集"
  },
  咸: {
    name: "咸",
    top: basicEightDiagrams.兑,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.三世,
    tip: "参与 遍布"
  },
  蹇: {
    name: "蹇",
    top: basicEightDiagrams.坎,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.四世,
    tip: "行险 难关"
  },
  谦: {
    name: "谦",
    top: basicEightDiagrams.坤,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.五世,
    tip: "谦逊 深藏不露"
  },
  小过: {
    name: "小过",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.艮,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.游魂,
    tip: "过火 可补救过失"
  },
  归妹: {
    name: "归妹",
    top: basicEightDiagrams.震,
    bottom: basicEightDiagrams.兑,
    host: basicEightDiagrams.兑,
    eachOther: eachOther.归魂,
    tip: "如愿 回报"
  },
};

const _sixtyYearsCycle = [];

export const getSixtyYearsCycle = () => {
  if (_sixtyYearsCycle.length == 60) return _sixtyYearsCycle;

  const stems = Object.keys(heavenStems);
  const branches = Object.keys(earthBranches);

  for (let i = 0; i < 60; i++) {
    _sixtyYearsCycle.push({
      heavenStem: heavenStems[stems[i % 10]],
      earthBranch: earthBranches[branches[i % 12]],
    });
  }

  return _sixtyYearsCycle;
};

export const getSortedSixtyYearsCycle = () => {
  // const cycles = getSixtyYearsCycle();
  // const ret = [];
  // for (const key in heavenStems) {
  //   const matchedCycles = cycles.filter((x) => x.heavenStem.name == key);
  //   for (const key2 in earthBranches){

  //   }
  //   ret.push(...matchedCycles);
  // }
  // return ret;
  const heavenStemKeys = Object.keys(heavenStems);
  const earthBranchKeys = Object.keys(earthBranches);
  return getSixtyYearsCycle().slice().sort((a, b) => {
    const stemA = heavenStemKeys.indexOf(a.heavenStem.name);
    const stemB = heavenStemKeys.indexOf(b.heavenStem.name);
    if (stemA < stemB) {  
      return -1;  
    } else if (stemA > stemB) {  
      return 1;  
    } else {  
      var branchA = earthBranchKeys.indexOf(a.earthBranch.name);  
      var branchB = earthBranchKeys.indexOf(b.earthBranch.name);  
        
      if (branchA < branchB) {  
          return -1;  
      } else if (branchA > branchB) {  
          return 1;  
      } else {  
          return 0;  
      }  
    }  
  });
};

export const sixGods = {
  青龙: {
    name: "青龙",
    element: fiveElements.木,
  },
  朱雀: {
    name: "朱雀",
    element: fiveElements.火,
  },
  勾陈: {
    name: "勾陈",
    element: fiveElements.土,
  },
  螣蛇: {
    name: "螣蛇",
    element: fiveElements.土,
  },
  白虎: {
    name: "白虎",
    element: fiveElements.金,
  },
  玄武: {
    name: "玄武",
    element: fiveElements.水,
  },
};

// export const getBornAndHelp = (earthBranch) => {
//   switch(earthBranch){
//     case earthBranches.亥:
//     case earthBranches.子:
//       return [earthBranches.子, earthBranches.亥, earthBranches.申, earthBranches.酉];
//     case earthBranches.寅:
//     case earthBranches.卯:
//       return [earthBranches.寅, earthBranches.卯, earthBranches.子, earthBranches.亥];
//     case earthBranches.巳:
//     case earthBranches.午:
//       return [earthBranches.巳, earthBranches.午, earthBranches.寅, earthBranches.卯];
//     case earthBranches.申:
//     case earthBranches.酉:
//       return [earthBranches.申, earthBranches.酉, earthBranches.丑, earthBranches.辰, earthBranches.未, earthBranches.戌];
//     case earthBranches.辰:
//       return [ earthBranches.丑, earthBranches.辰, earthBranches.未, earthBranches.巳, earthBranches.午];
//     case earthBranches.戌:
//       return [ earthBranches.丑, earthBranches.戌, earthBranches.未, earthBranches.巳, earthBranches.午];
//     case earthBranches.丑:
//       return [ earthBranches.丑, earthBranches.戌, earthBranches.辰, earthBranches.巳, earthBranches.午];
//     case earthBranches.未:
//       return [ earthBranches.未, earthBranches.戌, earthBranches.辰, earthBranches.巳, earthBranches.午];
//   }
// }

export const getBorn = (earthBranch) => {
  switch(earthBranch){
    case earthBranches.亥:
    case earthBranches.子:
      return [earthBranches.申, earthBranches.酉];
    case earthBranches.寅:
    case earthBranches.卯:
      return [earthBranches.子, earthBranches.亥];
    case earthBranches.巳:
    case earthBranches.午:
      return [earthBranches.寅, earthBranches.卯];
    case earthBranches.申:
    case earthBranches.酉:
      return [earthBranches.丑, earthBranches.辰, earthBranches.未, earthBranches.戌];
    case earthBranches.辰:
    case earthBranches.戌:
    case earthBranches.丑:
    case earthBranches.未:
      return [ earthBranches.巳, earthBranches.午];
  }
}

/**
 * 月支影响的分数表
 */
export const monthBranchRate = {
  子: {
    子: 2,
    丑: .5,
    寅: 1,
    卯: 1,
    辰: -.1,
    巳: -1,
    午: -2,
    未: -.1,
    申: -.1,
    酉: -.1,
    戌: -.1,
    亥: 1
  },
  丑: {
    子: -.5,
    丑: 2,
    寅: -.1,
    卯: -.1,
    辰: 1,
    巳: -.1,
    午: -.1,
    未: -2,
    申: 1,
    酉: 1,
    戌: 1,
    亥: -1
  },
  寅: {
    子: -.1,
    丑: -1,
    寅: 2,
    卯: 1,
    辰: -1,
    巳: 1,
    午: 1,
    未: -1,
    申: -2,
    酉: -.1,
    戌: -1,
    亥: .5
  },
  卯: {
    子: -.1,
    丑: -1,
    寅: 1,
    卯: 2,
    辰: -1,
    巳: 1,
    午: 1,
    未: -1,
    申: -.1,
    酉: -2,
    戌: -1,
    亥: -.1
  },
  辰: {
    子: -1,
    丑: 1,
    寅: .5,
    卯: .5,
    辰: 2,
    巳: -.1,
    午: -.1,
    未: 1,
    申: 1,
    酉: 2,
    戌: -2,
    亥: -1
  },
  巳: {
    子: -.1,
    丑: 1,
    寅: -.1,
    卯: -.1,
    辰: 1,
    巳: 2,
    午: 1,
    未: 1,
    申: -.5,
    酉: -1,
    戌: 1,
    亥: -2
  },
  午: {
    子: -2,
    丑: 1,
    寅: -.1,
    卯: -.1,
    辰: 1,
    巳: 1,
    午: 2,
    未: 2,
    申: -1,
    酉: -1,
    戌: 1,
    亥: -.1
  },
  未: {
    子: -1,
    丑: -2,
    寅: -.1,
    卯: -.1,
    辰: 1,
    巳: .5,
    午: .5,
    未: 2,
    申: 1,
    酉: 1,
    戌: 1,
    亥: -1
  },
  申: {
    子: 1,
    丑: -.1,
    寅: -2,
    卯: -1,
    辰: -.1,
    巳: .5,
    午: -.1,
    未: -.1,
    申: 2,
    酉: 1,
    戌: -.1,
    亥: 1
  },
  酉: {
    子: 1,
    丑: -.1,
    寅: -1,
    卯: -2,
    辰: .5,
    巳: -.1,
    午: -.1,
    未: -.1,
    申: 1,
    酉: 2,
    戌: -.1,
    亥: 1
  },
  戌: {
    子: -1,
    丑: 1,
    寅: -.1,
    卯: .5,
    辰: -2,
    巳: -.1,
    午: -.1,
    未: 1,
    申: 1,
    酉: 1,
    戌: 2,
    亥: -1
  },
  亥: {
    子: 1,
    丑: -.1,
    寅: 2,
    卯: 1,
    辰: -.1,
    巳: -2,
    午: -1,
    未: -.1,
    申: -.1,
    酉: -.1,
    戌: -.1,
    亥: 2
  },
};


/**
 * 日支影响的分数表
 */
export const dayBranchRate = {
  子: {
    子: 2,
    丑: 0,
    寅: 1,
    卯: 1,
    辰: 0,
    巳: -1,
    午: 0,
    未: 0,
    申: 0,
    酉: 0,
    戌: 0,
    亥: 1
  },
  丑: {
    子: -1,
    丑: 2,
    寅: 0,
    卯: 0,
    辰: 1,
    巳: 0,
    午: 0,
    未: 0,
    申: 1,
    酉: 1,
    戌: 1,
    亥: -1
  },
  寅: {
    子: 0,
    丑: -1,
    寅: 2,
    卯: 1,
    辰: -1,
    巳: 1,
    午: 1,
    未: -1,
    申: 0,
    酉: 0,
    戌: -1,
    亥: 0
  },
  卯: {
    子: 0,
    丑: -1,
    寅: 1,
    卯: 2,
    辰: -1,
    巳: 1,
    午: 1,
    未: -1,
    申: 0,
    酉: 0,
    戌: -1,
    亥: 0
  },
  辰: {
    子: -1,
    丑: 1,
    寅: 0,
    卯: 0,
    辰: 2,
    巳: 0,
    午: 0,
    未: 1,
    申: 1,
    酉: 2,
    戌: 0,
    亥: -1
  },
  巳: {
    子: 0,
    丑: 1,
    寅: 0,
    卯: 0,
    辰: 1,
    巳: 2,
    午: 1,
    未: 1,
    申: -1,
    酉: -1,
    戌: 1,
    亥: 0
  },
  午: {
    子: 0,
    丑: 1,
    寅: 0,
    卯: 0,
    辰: 1,
    巳: 1,
    午: 2,
    未: 2,
    申: -1,
    酉: -1,
    戌: 1,
    亥: 0
  },
  未: {
    子: -1,
    丑: 0,
    寅: 0,
    卯: 0,
    辰: 1,
    巳: 0,
    午: 0,
    未: 2,
    申: 1,
    酉: 1,
    戌: 1,
    亥: -1
  },
  申: {
    子: 1,
    丑: 0,
    寅: 0,
    卯: -1,
    辰: 0,
    巳: 0,
    午: 0,
    未: 0,
    申: 2,
    酉: 1,
    戌: 0,
    亥: 1
  },
  酉: {
    子: 1,
    丑: 0,
    寅: -1,
    卯: 0,
    辰: 0,
    巳: 0,
    午: 0,
    未: 0,
    申: 1,
    酉: 2,
    戌: 0,
    亥: 1
  },
  戌: {
    子: -1,
    丑: 1,
    寅: 0,
    卯: 0,
    辰: 0,
    巳: 0,
    午: 0,
    未: 1,
    申: 1,
    酉: 1,
    戌: 2,
    亥: -1
  },
  亥: {
    子: 1,
    丑: 0,
    寅: 2,
    卯: 1,
    辰: 0,
    巳: 0,
    午: -1,
    未: 0,
    申: 0,
    酉: 0,
    戌: 0,
    亥: 2
  },
};

export const rhythm = 
{ 甲子: "海中金", 乙丑: "海中金", 丙寅: "炉中火", 丁卯: "炉中火", 
戊辰: "大林木", 己巳: "大林木", 庚午: "路旁土", 辛未: "路旁土", 
壬申: "剑锋金", 癸酉: "剑锋金", 甲戌: "山头火", 乙亥: "山头火", 
丙子: "涧下水", 丁丑: "涧下水", 戊寅: "城头土", 己卯: "城头土", 
庚辰: "白蜡金", 辛巳: "白蜡金", 壬午: "杨柳木", 癸未: "杨柳木", 
甲申: "泉中水", 乙酉: "泉中水", 丙戌: "屋上土", 丁亥: "屋上土", 
戊子: "霹雳火", 己丑: "霹雳火", 庚寅: "松柏木", 辛卯: "松柏木", 
壬辰: "长流水", 癸巳: "长流水", 甲午: "沙中金", 乙未: "沙中金", 
丙申: "山下火", 丁酉: "山下火", 戊戌: "平地木", 己亥: "平地木", 
庚子: "壁上土", 辛丑: "壁上土", 壬寅: "金箔金", 癸卯: "金箔金", 
甲辰: "覆灯火", 乙巳: "覆灯火", 丙午: "天河水", 丁未: "天河水", 
戊申: "大驿土", 己酉: "大驿土", 庚戌: "钗钏金", 辛亥: "钗钏金", 
壬子: "桑柘木", 癸丑: "桑柘木", 甲寅: "大溪水", 乙卯: "大溪水", 
丙辰: "沙中土", 丁巳: "沙中土", 戊午: "天上火", 己未: "天上火", 
庚申: "石榴木", 辛酉: "石榴木", 壬戌: "大海水", 癸亥: "大海水"};

// /**
//  * 初始化
//  */
// (function () {
//   //安装每一卦的地支和六亲
//   for (const key in sixtyFourDiagrams) {
//     const sixMembers = getSixMembers(sixtyFourDiagrams[key]);
//     sixtyFourDiagrams[key].sixMembers = sixMembers;
//   }
// })();
